package com.shiroha.notification.controller;

import com.shiroha.common.utils.Result;
import com.shiroha.notification.service.IEmailService;
import lombok.AllArgsConstructor;
import org.springframework.web.bind.annotation.*;

@RestController
@RequestMapping("/ns/email")
@AllArgsConstructor
public class EmailController {

    private final IEmailService emailService;

    @PostMapping("/post")
    public Result<String> sendEmailCode(@RequestParam String email) {
        emailService.sendEmailCode(email);
        return Result.success("邮件发送成功");
    }

    @GetMapping("/check")
    public Result<Boolean> checkCode(@RequestParam String email, @RequestParam String code) {
        return Result.success(emailService.checkCode(email, code));
    }
}
